﻿using System.Windows;
using System.Windows.Controls;
using ScrumTable.UI.View.CustomControl;
using ScrumTable.UI.View.Util;

namespace ScrumTable.UI.View.WinTouch.UserControls.SubControls
{
	/// <summary>
    /// Interaction logic for AddChildTaskControl.xaml
	/// </summary>
    public partial class AddChildTaskControl
	{
        public AddChildTaskControl()
        {
            InitializeComponent();
        }

        private void OnTaskControlPreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            BringItemToFront(sender);
        }

        private void OnTaskControlPreviewTouchDown(object sender, System.Windows.Input.TouchEventArgs e)
        {
            BringItemToFront(sender);
        }


        private void BringItemToFront(object sender)
        {
            var cont = ViewElementUtils.FindVisualChild<StackPanelAnimated2>(ListProject);
            var uiElement = (FrameworkElement)sender;

            foreach (FrameworkElement children in cont.Children)
            {
                Grid.SetZIndex(children, 0);
                if (children.DataContext == uiElement.DataContext)
                {
                    children.SetValue(Canvas.ZIndexProperty, 999);
                }
            }
        }
       
	}
}